//
//  ViewController.m
//  XSDataBaseDemo
//
//  Created by 大帅 on 2023/12/19.
//

#import "ViewController.h"

#import "XSAddViewController.h"
#import "XSDelViewController.h"
#import "XSUpdateViewController.h"
#import "XSAllListViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.navigationItem.title = @"home";
    self.view.backgroundColor = [UIColor.greenColor colorWithAlphaComponent:0.5];
    
    CGFloat temp_y = 100;
    NSArray *arr = @[@"增", @"删", @"改", @"查"];
    for (int i = 0; i < arr.count; i ++) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setTitle:arr[i] forState:UIControlStateNormal];
        [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [button setBackgroundColor:[UIColor whiteColor]];
        button.tag = i + 100;
        [button addTarget:self action:@selector(clickButton:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:button];
        [button mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(20);
            make.top.mas_equalTo(temp_y + (45 + 20) * i);
            make.size.mas_offset(CGSizeMake(100, 45));
        }];
    }
    
}

-(void)clickButton:(UIButton *)sender {
    if (sender.tag == 100) {
        // Z
        XSAddViewController *vc = [[XSAddViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    } else if (sender.tag == 101) {
        // S
        XSDelViewController *vc = [[XSDelViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    } else if (sender.tag == 102) {
        // G
        XSUpdateViewController *vc = [[XSUpdateViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    } else if (sender.tag == 103) {
        // C
        XSAllListViewController *vc = [[XSAllListViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    }
}


@end
